//
//  WPInputGoldCountVC.m
//  wobingwoyi
//
//  Created by WGP on 16/8/4.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPInputGoldCountVC.h"
#import "WPWithdrawalVC.h"

@interface WPInputGoldCountVC ()

@property (weak, nonatomic) IBOutlet UITextField *coinField;
@property (weak, nonatomic) IBOutlet UILabel *totalCoinLabel;

@end

@implementation WPInputGoldCountVC

- (void)viewDidLoad
{
    [super viewDidLoad];
   
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    
    self.totalCoinLabel.text = [NSString stringWithFormat:@"金币数 %zd,",self.coinCount];
}

- (IBAction)cancelBtnDidClick:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)allWithDrawBtnDidClick:(UIButton *)sender
{
    self.coinField.text = [NSString stringWithFormat:@"%zd",self.coinCount];
    [self.coinField becomeFirstResponder];
}
- (IBAction)nextStep:(UIButton *)sender
{
    int coinNum;
    
    if (!self.coinField.text.length)
    {
        coinNum = 500;
    }
    else
    {
        coinNum = [self.coinField.text intValue];
    }
    
    if (coinNum < 500)
    {
        [self showErrorInfoWithStatus:@"提现金币不能低于500"];
        return ;
    }
    
    if (coinNum > self.coinCount)
    {
        [self showErrorInfoWithStatus:@"提现金币大于已有金币数"];
        return ;
    }
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"WPWithdrawalVC" bundle:nil];
    WPWithdrawalVC *vc = [sb instantiateInitialViewController];
    vc.coinCountStr = self.coinField.text.length ? self.coinField.text : self.coinField.placeholder;
    
    [self.navigationController pushViewController:vc animated:YES];
}

@end
